package org.miframework.arqsw.tags;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

@SuppressWarnings("serial")
public class Error extends TagSupport {
	private String tipo,color;
	

	public void setTipo(String tipo) {
		this.tipo = tipo;
	}

	public void setColor(String color) {
		this.color = color;
	}
	
	public void convertir(){
		if(color.equals("rojo")){
			color="red";
		}else if(color.equals("verde")){
			color="green";
		}else if(color.equals("amarillo")){
			color="yellow";
		}else{
			color="blue";
		}
	}



	@Override
	public int doStartTag() throws JspException {
		convertir();
		JspWriter out = pageContext.getOut();
		try {
			
			out.print("<table border=2 height=50 width=180 bgcolor="+color+">");
				out.print("<tr>");
					out.print("<td align='center'>"+tipo+" :: "+color+ "</td>");
				out.print("</tr>");
			
			out.print("</table>");			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SKIP_BODY;
	}
	
}